#include "solve.h"
#include "bigint.h"
#include <string>
#include <iostream>
bool Solve(BigInt const & a, BigInt const & b, std::string act, BigInt& ans)
{
	if(act == "+") 
	{
		ans = a + b;
		return true;
	}
	if(act == "-")
	{
		ans = a - b;
		return true;
	}
	if(act == "*")
	{
		ans = a * b;
		return true;
	}
	if(act == "/")
	{
		if(b == BigInt(0) || b.RealSize() == 0)
			return false;
		ans = a / b;
		return true;
	}
	return false;
}
bool Solve(double a, double b, std::string act, double * ans)
{
	if(act == "+") 
	{
		*ans = a + b;
		return true;
	}
	if(act == "-") 
	{
		*ans = a - b;
		return true;
	}
	if(act == "*") 
	{
		*ans = a * b;
		return true;
	}
	if(act == "/") 
	{
		if(b == 0) 
		{
			*ans = 0;
			return false;
		}
		else
		{
			*ans = a / b;
			return true;
		}
	}
	return false;
}
